import  {Token}  from '@/types/data'


// 使用常量来存储 key
const GEEK_TOKEN_KEY = 'geek-h5-token';

// 创建获取Token  

export const  getToken=():Token=>{
     return   JSON.parse(localStorage.getItem(GEEK_TOKEN_KEY) ?? '{ "token": "", "refresh_token": "" }') as Token
}


// 创建 设置 token  

export  const  setToken=(token:Token)=>{
     localStorage.setItem(GEEK_TOKEN_KEY,JSON.stringify(token))
}

// 创建清除token  
export const  clearToken=()=>localStorage.removeItem(GEEK_TOKEN_KEY)


//  创建根据token  判断 是否登录 

export const  isAuth=()=>!!getToken()

